#include "StdAfx.h"
#include "GLoginDlg.h"
#include "GEdit.h"
#include "GButton.h"
#include "GSocket.h"
#include "GDlgMgr.h"
#include "GTeamDlg.h"
#include "Player.h"

GLoginDlg::GLoginDlg(void)
{
	m_bEnableMove = FALSE;
}

GLoginDlg::~GLoginDlg(void)
{
}

DWORD GLoginDlg::HandleEvent(DWORD hwnd)
{
	if (hwnd == m_pBtnLogin->GetWnd())
	{
		Player::GetLocalPlayer()->Init();
		if(sGSocket.IsConnectiong() == false)
			if(sGSocket.ConnectServer()== false)
				return 0;
		tagNC_PlayerAuthSession msg;
		strncpy(msg.szName, conversion::wstr2astr(m_pEditAcount->m_strText).c_str(), 32);
		strncpy(msg.szPassword, conversion::wstr2astr(m_pEditPassword->m_strText).c_str(), 32);
		sGSocket.SendMsg(&msg, msg.dwSize);
	}
	return 0;
}
DWORD GLoginDlg::SetSubWnd()
{
	m_pEditAcount = (GEdit*)GetWnd(1);
	m_pEditPassword = (GEdit*)GetWnd(2);
	m_pStatic = (GStatic*)GetWnd(3);
	m_pBtnLogin = (GButton*)GetWnd(4);
	return 0;
}
